package br.com.klis.easycontrast;

import android.os.CountDownTimer;
import br.com.klis.easycontrast.view.ContrastSessionViewInterface;

public class AppCountDownTimer extends CountDownTimer{
	private ContrastSessionViewInterface display;
	private int minutes;
	private int seconds;
	
	public AppCountDownTimer(ContrastSessionViewInterface display, int minutes, int seconds) {
		super((1000 * 60 * minutes) + (1000 * seconds), 1000);
		this.minutes = minutes;
		this.seconds = seconds;
		this.display = display;
	}

	@Override
	public void onFinish() {
		display.updateTextView(0, 0);
		display.finishTime();
	}

	@Override
	public void onTick(long millisUntilFinished) {
		if ( seconds > 0 )
			seconds--;
		else if ( minutes > 0){
			seconds = 59;
			minutes--;
		}
		display.updateTextView(minutes, seconds);
	}
}